package com.iogame.iogamevalidatortest.javaxserver;

import com.iohao.game.action.skeleton.ext.spring.ActionFactoryBeanForSpring;
import com.iohao.game.bolt.broker.client.external.ExternalServer;
import com.iohao.game.bolt.broker.client.external.config.ExternalGlobalConfig;
import com.iohao.game.bolt.broker.server.BrokerServer;
import com.iohao.game.common.validation.annotation.EnableValidation;
import com.iohao.game.common.validation.support.JavaxValidator;
import com.iohao.game.simple.SimpleRunOne;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

import java.util.List;

@EnableValidation("com.iohao.game.common.validation.support.JavaxValidator")
@SpringBootApplication
public class JavaXServerApplication {

    public static void main(String[] args) {
        SpringApplication.run(JavaXServerApplication.class, args);

        ExternalGlobalConfig.accessAuthenticationHook
                .setVerifyIdentity(true)
                .addIgnoreAuthenticationCmd(1, 1);

        int port = 10100;
        ExternalServer externalServer = ExternalServer.newBuilder(port).build();

        // broker （游戏网关）
        BrokerServer brokerServer = BrokerServer.newBuilder().port(10200).build();
        new SimpleRunOne()
                .setBrokerServer(brokerServer)
                .setExternalServer(externalServer)
                .setLogicServerList(List.of(new DemoLogicServer()))
                .startup();

    }

    @Bean
    public ActionFactoryBeanForSpring actionFactoryBean() {
        // 将业务框架交给 spring 管理
        return ActionFactoryBeanForSpring.me();
    }
}


